package com.xmall.auth.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmall.auth.entity.SysPermission;
import com.xmall.auth.entity.SysResource;
import com.xmall.auth.entity.SysRole;
import com.xmall.auth.xmallauth.jwt.model.LoginUser;
import com.xmall.common.model.SysUser;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 服务类
 * </p>
 *
 * @author liuzh
 * @since 2020-05-16
 */
public interface ISysUserService extends IService<SysUser>  {

    boolean registerUser(SysUser sysUser);

    boolean updateUser(SysUser sysUser,  LambdaQueryWrapper<SysUser> queryWrapper);

    boolean deleteUser(Long id);

    Map<String, String> login(LoginUser loginUser);

    Map<String, Object> getAdminInfo(String userName);

    /**
     * 修改用户角色关系
     */
    @Transactional
    int updateRole(Long adminId, List<Long> roleIds);

    /**
     * 获取用户对于角色
     */
    List<SysRole> getRoleList(Long adminId);

    /**
     * 获取指定用户的可访问资源
     */
    List<SysResource> getResourceList(Long adminId);

    /**
     * 修改用户的+-权限
     */
    @Transactional
    int updatePermission(Long adminId, List<Long> permissionIds);

    /**
     * 获取用户所有权限（包括角色权限和+-权限）
     */
    List<SysPermission> getPermissionList(Long adminId);

}
